package com.allo2o.common.service;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.allo2o.shared.util.FileUtil;

/**
 * 生成接口和实现接口类文件
 *
 */
public class CreateClass {

    public static void main(String[] args) {
        String pathService = "src/main/java/com/lechinepay/allo2o/common/service/";
        String pathServiceImpl = "src/main/java/com/lechinepay/allo2o/common/service/impl/";
        String contentService = "package com.allo2o.common.service;\r\npublic interface ";
        String contentServiceImpl = "package com.allo2o.common.service.impl;\r\n\r\n"
                + "import org.springframework.stereotype.Service;\r\n"
                + "import com.allo2o.common.service.%s;\r\n\r\n"
                + "@Service\r\n"
                + "public class %s implements %s {\r\n\r\n}";
        
        List<String> classNameList = new ArrayList<String>();
//        classNameList.add("UserPhoto");
//        classNameList.add("CmpLifePhoto");
//        classNameList.add("CommonHelp");
//        classNameList.add("Company");
        classNameList.add("SysUser");
        
        
        try {
            for(int i=0; i<classNameList.size(); i++){
                String className = "I"+classNameList.get(i)+"Service";
                File file = new File(pathService+className+".java");
                boolean bool = FileUtil.createFile(file);
                if(bool){
                    
                    String content = contentService+className+"{}";
                    boolean b = FileUtil.writeTxtFile(content, file);
                    if(b){
                        System.out.println(className+"生成成功");
                    }
                }
                
                String className1 = classNameList.get(i)+"ServiceImpl";
                File file1 = new File(pathServiceImpl+className1+".java");
                boolean bool1 = FileUtil.createFile(file1);
                if(bool1){
                    String content = String.format(contentServiceImpl, className,className1,className);
                    boolean b = FileUtil.writeTxtFile(content, file1);
                    if(b){
                        System.out.println(className1+"生成成功");
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

   
}
